#!/bin/bash
#SPASIBO ZA KOMMENTARII, BSE OCHEM PONYATNO//
function addShip()
{
 let y1=${ship:0:1}
 let x1=${ship:1:1}
 let y2=${ship:2:1}
 let x2=${ship:3:1}
 
if [[ "$ship" =~ ^[0-9]{4}$ ]] && [[ $x1 == $x2 || $y1 == $y2 ]];then
    for((i=$x1;i<=$x2;i++));do       
       for((j=$y1;j <=$y2;j++));do
          field[j*10+i]=""
       done
    done
 else
      echo "Error"
fi
}

for ((i=0;i<100;i++));do
  		field[i]="*";
done

for ship in $@; do
  addShip
done

a=0

for((i=0;i<=100;i++));do
  if [[ $a -eq 0 ]];then 
    echo ""; 
    a=$a+1;
  else a=$a+1; 
  fi
  if [[ $a -eq 10 ]];then a=0; fi
  echo -n ${field[i]}
  
done
